package com.sugon.service.impl;

import cn.hutool.core.util.RandomUtil;
import com.sugon.dao.ToolsStockDao;
import com.sugon.entity.ToolsStockEntity;
import com.sugon.service.ToolsStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import static com.sugon.utils.ShiroUtils.getUserId;

/**
 * 工装库存Service实现类
 *
 * @author sugon
 * @date 2019-08-03 16:20:29
 */
@Service("toolsStockService")
public class ToolsStockServiceImpl implements ToolsStockService {
    @Autowired
    private ToolsStockDao toolsStockDao;

    @Override
    public ToolsStockEntity queryObject(String id) {
        return toolsStockDao.queryObject(id);
    }

    @Override
    public List<ToolsStockEntity> queryList(Map<String, Object> map) {
        return toolsStockDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return toolsStockDao.queryTotal(map);
    }

    @Override
    public int save(ToolsStockEntity toolsStock) {
        toolsStock.setId(RandomUtil.randomString(32));
        toolsStock.setCreateTime(new Date());
        toolsStock.setCreateUser(getUserId());
//        toolsStock.setErpCode("TOOLS-"+new Date().getTime());
        toolsStock.setDelFlag(1);
        return toolsStockDao.save(toolsStock);
    }

    @Override
    public int update(ToolsStockEntity toolsStock) {
        return toolsStockDao.update(toolsStock);
    }

    @Override
    public int delete(String id) {
        return toolsStockDao.delete(id);
    }

    @Override
    public int deleteBatch(String[] ids) {
        return toolsStockDao.deleteBatch(ids);
    }

    @Override
    public ToolsStockEntity queryByCode(String erpCode) {
        return toolsStockDao.queryByCode(erpCode);
    }

    @Override
    public int queryValid(ToolsStockEntity toolsStock) {
        return toolsStockDao.queryValid(toolsStock);
    }
}
